package com.woniuxy04;

class Aaa{

    int x;

    public Aaa() {
        System.out.println("父类无参构造");
    }

    public Aaa(int x) {
        System.out.println("父类带参构造");
        this.x = x;
    }
}

class Bbb extends Aaa{
    int y;

    public Bbb() {
        //调用父类的构造方法,不写，默认也是这么执行
        super();
        System.out.println("子类无参构造");
    }

    public Bbb(int x,int y) {
        //调用父类的带参构造
        super(x);
        System.out.println("子类带参构造");
        this.y = y;
    }

    public void test(){
        System.out.println("x="+x+",y="+y);
    }
}

public class Test01 {
    public static void main(String[] args) {
        //创建子类对象
        Bbb b1 = new Bbb();
        System.out.println("-------------");
        Bbb b2 = new Bbb(11,2);
        b2.test();
    }
}
